<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<div class="menu_list">
<table id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
	<?php if($item['id'] > 0): ?>
	<tr>
		<th nowrap="nowrap" colspan="4"><input type="submit" value="Save" style="float:left; padding-left:20px; padding-right:10px;  background-image: url('../images/system/save.gif'); border:1px solid #DDDDDD; height:20px;" class="buttons"></th>
		<th nowrap="nowrap" colspan="4">
			<input type="hidden" name="action" value="update">
			<button name="delete_menu" value="<?php echo $item['id']; ?>" style="float:right; padding-left:20px; padding-right:10px;  background-image: url('../images/system/delete.gif'); border:1px solid #DDDDDD;" class="buttons">
				Delete 
				<?php if($item['parent_id'] == 0): ?>
				Menu
				<?php else: ?>
				Item
				<?php endif;?>
			</button>
		</th>
	</tr>
	<?php endif; ?>
	<tr>
		<th nowrap="nowrap">#&nbsp;ID&nbsp;&nbsp;<input type="hidden" name="item" value="<?php echo $_REQUEST['item']; ?>"></th>
		<th nowrap="nowrap">Title&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Link Type&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Link Location&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Access Level&nbsp;&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Order&nbsp;&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Active&nbsp;&nbsp;&nbsp;</th>
		<th nowrap="nowrap">Edit&nbsp;&nbsp;&nbsp;</th>
		<th nowrap="nowrap"><?php echo ucfirst($txt->getWord('delete')); ?></th>
	</tr>
	<tr class="new_item">
		<td nowrap="nowrap">#&nbsp;0</td>
		<td nowrap="nowrap"><input class="inp_txt" name="title" type="text" value="" ></td>
		<td nowrap="nowrap">
			<select name="item_type">
            	<?php if($item['link_type'] != 6): ?>
				<option value="0" <?php echo getIsSelectedHTML($_POST['item_type'], 0);  ?>>Menu Folder</option>
				<option value="1" <?php echo getIsSelectedHTML($_POST['item_type'], 1);  ?>>Local URL</option>
				<option value="2" <?php echo getIsSelectedHTML($_POST['item_type'], 2);  ?>>Remote URL</option>
				<option value="3" <?php echo getIsSelectedHTML($_POST['item_type'], 3);  ?>>Content Page</option>
				<option value="4" <?php echo getIsSelectedHTML($_POST['item_type'], 4);  ?>>Component</option>
				<option value="5" <?php echo getIsSelectedHTML($_POST['item_type'], 5);  ?>>Static HTML Page</option>
                <?php endif; ?>
                <option value="6" <?php echo getIsSelectedHTML($_POST['item_type'], 6);  ?>>Product Section</option>
			</select>
		</td>
		<td colspan="4" nowrap="nowrap"><button name="add_item" value="1" style="padding-left:20px; padding-right:10px;  background-image: url('../images/system/new.gif'); border:1px solid #DDDDDD;" class="buttons">Add Item</button></td>
	</tr>
	<?php 
	if($subitems):
	foreach($subitems as $subitem)
	{
		$components = $siteAdmin->getSiteComponents();
	?>
	<tr class="items">
		<td nowrap="nowrap">#&nbsp;<input type="hidden" name="sub_id[]" value="<?php echo $subitem['id']; ?>" /><?php echo $subitem['id']; ?></td>
		<td nowrap="nowrap"><input class="inp_txt" name="sub_title[]" type="text" value="<?php echo $subitem['title']; ?>"  /></td>
		<td nowrap="nowrap">
			<select name="link_type[]" onchange="submit();">
				<option value="0" <?php if($subitem['link_type'] == 0){ echo 'selected'; } ?>>Menu Folder</option>
				<option value="1" <?php if($subitem['link_type'] == 1){ echo 'selected'; } ?>>Local URL</option>
				<option value="2" <?php if($subitem['link_type'] == 2){ echo 'selected'; } ?>>Remote URL</option>
				<option value="3" <?php if($subitem['link_type'] == 3){ echo 'selected'; } ?>>Content Page</option>
				<option value="4" <?php if($subitem['link_type'] == 4){ echo 'selected'; } ?>>Component</option>
				<option value="5" <?php if($subitem['link_type'] == 5){ echo 'selected'; } ?>>Static HTML Page</option>
                <option value="6" <?php if($subitem['link_type'] == 6){ echo 'selected'; } ?>>Product Section</option>
			</select>
		</td>
		<td nowrap="nowrap">
			<?php if(($subitem['link_type'] == 1) || ($subitem['link_type'] == 2)): ?>
			<input class="inp_txt" name="link_url[]" type="text" value="<?php echo $subitem['link_url']; ?>" />
			<input name="link_id[]" type="hidden" value="0" />
			<?php endif;?>
			<?php if($subitem['link_type'] == 3): ?>
			<select name="link_id[]" onchange="submit();">
				<?php
				foreach($pages as $page)
				{
					if($subitem['link_id'] == $page['id'])
					{ echo '<option value="'.$page['id'].'" selected>'.$page['title'].'</option>'; }
					else
					{ echo '<option value="'.$page['id'].'">'.$page['title'].'</option>'; }
				}
				?>
			</select>
			<?php endif;?>
			<?php if($subitem['link_type'] == 4): ?>
			<select name="link_id[]" onchange="submit();">
				<?php
				foreach($components as $component)
				{
					if($subitem['link_id'] == $component['id'])
					{ echo '<option value="'.$component['id'].'" selected>'.$component['name_l'].' '.$component['name_r'].'</option>'; }
					else
					{ echo '<option value="'.$component['id'].'">'.$component['name_l'].' '.$component['name_r'].'</option>'; }
				}
				?>
			</select>
			<?php endif;?>
			<?php if($subitem['link_type'] == 5): ?>
			<select name="link_id[]" onchange="submit();">
				<?php
				foreach($contpages as $cont)
				{
					if($subitem['link_id'] == $cont['id'])
					{ echo '<option value="'.$cont['id'].'" selected>'.$cont['name_l'].' '.$cont['name_r'].'</option>'; }
					else
					{ echo '<option value="'.$cont['id'].'">'.$cont['name_l'].' '.$cont['name_r'].'</option>'; }
				}
				?>
			</select>
			<?php endif;?>
			<?php if($subitem['link_type'] == 0): ?>
			<?php echo '?menu='.$subitem['id']; ?>
			<input name="link_id[]" type="hidden" value="0" />
			<input name="link_url[]" type="hidden" value="" />
			<?php endif;?>
		</td>
		<td nowrap="nowrap">
			<?php 
				if($subitem['access'] == 0)
				{ $bg = 'access_0.gif'; }
				else
				{ $bg = 'access_1.gif'; }
			?>
			<select name="access[]" onchange="submit();" style="background:transparent url(../images/system/<?php echo $bg; ?>) no-repeat scroll left top; padding-left:18px;" >
				<?php
				foreach($groups as $group)
				{
					if($subitem['access'] == $group['id'])
					{ echo '<option value="'.$group['id'].'" selected>'.$group['name'].'</option>'; }
					else
					{ echo '<option value="'.$group['id'].'">'.$group['name'].'</option>'; }
				}
				?>
			</select>
		</td>
		<td nowrap="nowrap">
			<img src="../images/system/arrow_up_20.gif" onmousedown="document.getElementById('up').value='<?php echo $subitem['id']; ?>';" onmouseup="edit_form.submit();" />
			<img src="../images/system/arrow_down_20.gif" value="0" onmousedown="document.getElementById('down').value='<?php echo $subitem['id']; ?>';" onmouseup="edit_form.submit();" />
		</td>
		<td nowrap="nowrap">
			<?php if($subitem['active'] == 0): ?>
			<img src="../images/system/active_<?php echo $subitem['active']; ?>_25.gif" alt="activate" onmousedown="document.getElementById('activate').value='<?php echo $subitem['id']; ?>';" onmouseup="edit_form.submit();" />
			<?php else: ?>
			<img src="../images/system/active_<?php echo $subitem['active']; ?>_25.gif" alt="deactivate" onmousedown="document.getElementById('deactivate').value='<?php echo $subitem['id']; ?>';" onmouseup="edit_form.submit();" />
			<?php endif; ?>
		</td>
		<td nowrap="nowrap">
			<?php if($subitem['link_type'] == 3): ?>
			<a href="?con=3&item=<?php echo $subitem['link_id']; ?>"><img src="../images/system/templ.gif" border="0" /></a>
			<?php endif; ?>
			<?php if($subitem['link_type'] == 5): ?>
			<a href="?con=3&item=<?php echo $subitem['link_id']; ?>"><img src="../images/system/html.gif" border="0" /></a>
			<?php endif; ?>&nbsp;
		</td>
		<td nowrap="nowrap"><input class="inp_image" type="image" name="delete_item" src="../images/system/trash_25.gif" value="0" onclick="this.value='<?php echo $subitem['id']; ?>'; edit_form.submit();" /></td>
	</tr>
	<?php
	}
	?>
    <?php endif; ?>
</table>
<input type="hidden" id="up" name="up" value="0" />
<input type="hidden" id="down" name="down" value="0" />
</div>


